var maxFrames = 3;
var parrotFrame = 1;
var navigationHeight = 65;
var navigationHide;
var navigationHideDisabled = true;
var navigationShowing = false;

$(document).ready(function() {
	$('#parrot').hide();
	$(window).load(function() {
		$('#parrot').fadeIn('fast').slideDown();
		setInterval(moveParrot, 5000);
		setTimeout('showDot(".s1")', 500);
		setTimeout('showDot(".s2")', 1000);
		setTimeout('showDot("#bubble")', 1500);
	});
	$(document).mousemove(function(e) {
		var x1 = $('#bubble').offset().left;
		var y1 = $('#bubble').offset().top;		
		var x2 = x1 + $('#bubble').width();
		var y2 = y1 + $('#bubble').height();
		var x = e.pageX;
		var y = e.pageY;
		navigationHideDisabled = (x >= x1 && x < x2 && y > y1 && y < y2);
		if (x1 > 0) {
			if (!navigationShowing) {
				navigationShowing = true;
				$('#navigation').fadeIn('fast');
				$('#bubble').animate( { height: '+=' + navigationHeight + 'px' }, 200);
				if (navigationHide) {
					clearTimeout(navigationHide);
				}
				navigationHide = setTimeout(hideNavigation, 2000);
			} else if (!navigationHideDisabled) {
				if (navigationHide) {
					clearTimeout(navigationHide);
				}			
				navigationHide = setTimeout(hideNavigation, 2000);
			}
		}
		
	});
});

function hideNavigation() {
	if (!navigationHideDisabled) {
		$('#navigation').fadeOut('fast');
		$('#bubble').animate( { height: '-=' + navigationHeight + 'px' }, 200, function() {
			navigationShowing = false;		
		});
	}	
}

function moveParrot() {
	lastFrame = parrotFrame;
	parrotFrame = Math.ceil(Math.random() * (maxFrames - 1)) + 1;
	if (lastFrame != parrotFrame) {
		$('#parrot').attr('src', '/img/parrot' + parrotFrame + '.jpg');
	}
}

function showDot(selector) {
	$(selector).fadeIn('slow');
}

var tzo = new Date().getTimezoneOffset();        
document.cookie = "timezoneOffset=" + escape(tzo * (-1));